<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link type="text/css" href="/css/start/jquery-ui-1.8.21.custom.css" rel="Stylesheet" />	
<script type="text/javascript" src="/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="/js/jquery-ui-1.8.21.custom.min.js"></script>
<script src="//tinymce.cachefly.net/4.1/tinymce.min.js"></script>
<script>
        tinymce.init({selector:'textarea.withtinymce'});
</script>


</head>

<body style="font-family:Arial, Helvetica, sans-serif">
<h2>Add Current Repair Lost ( Cycle: <?php echo $this->cycle;?> )</h2>
<?php if(!$this->newStockLost){?>
	<?php $stockLost = new Model_DbTable_Products_Stock_Stocklost(Zend_Registry::get('db_remoteapp'));
		  $dateBegin = $this->dateBegin;
		  $dateEnd = $this->dateEnd;
		  ?>

   <form id="form1" name="form1" method="post" action="">
  	<p>Period:  
       <input type="text" name="period_begin" id="period_begin" value="<?php echo $this->dateBegin?>" readonly="readonly"/>
       <em>To</em>
	   <input type="text" name="period_end" id="period_end" value="<?php echo $this->dateEnd?>" readonly="readonly"/>
    </p>
    <br/> 
   
  <table width="600" border="1" cellspacing="0" cellpadding="15" style="font-size:13px;">
  	<tr>
  		<th>Shop</th>
  		<th>Before StockLost</th>
  		<th>Current StockLost</th>
  	</tr>
  	<?php $shopList = unserialize(ARR_SHOP_GROUP);?>
      <?php foreach($this->stocklost as $key => $val){
      			$totalLost = 0;
      			$currentStockLost = $stockLost->getAllStockLostByShopIdTypePeriod($val['shop_id'], 7, $dateBegin, $dateEnd);
      			if(!$currentStockLost){
      				$totalLost = 0;
      			}else{
      				foreach($currentStockLost as $k => $v){
      					$totalLost += $v['stock_lost'];
					}
				}?>
  <tr>
    <td><input type="text" name="shop_code[<?php echo $val['shop_id']?>]" id="shop_code<?php echo $val['shop_id']?>" value="<?php echo $val['shop_code']?>" readonly="readonly" /></td>     
	<td><input type="text" name="bf_stocklost[<?php echo $val['shop_id']?>]" id="bf_stocklost<?php echo $val['shop_id']?>" value="<?php if($val['before_stocklost']){echo $val['before_stocklost'];}else{ echo 0;}?>" readonly="readonly"/></td>
	<td><input type="text" name="current_stocklost[<?php echo $val['shop_id']?>]" id="current_stocklost<?php echo $val['shop_id']?>" value="<?php echo $totalLost;?>" /></td>
    <?php }?> 

  </tr>

  <tr>
    <td colspan="4" align="center"><span style = "color:red;">Please double check every detail then click submit, you may not delete it if you made mistakes</span><br />
      <input type="submit" name="button" id="button" value="Submit&Next" /><br /></td>
  </tr>
</table>
</form>
  <br/><br/>
<?php }else{?>
<form id="form2" name="form2" method="post" action="">
  	<p>Period:  
       <input type="text" name="period_begin" id="period_begin" value="<?php echo $this->dateBegin?>" />
       <em>To</em>
	   <input type="text" name="period_end" id="period_end" value="<?php echo $this->dateEnd?>" />
    </p>
    <br/> 
   
  <table width="900" border="1" cellspacing="0" cellpadding="15" style="font-size:13px;">
  	<tr>
  		<th>Shop</th>
  		<th>Before StockLost</th>
  		<th>Current StockLost</th>
  		<th>Total StockLost</th>
  		<th>Adjusted StockLost</th>
  	</tr>
  	<?php $shopList = unserialize(ARR_SHOP_GROUP);?>
      <?php foreach($this->newStockLost as $key2 => $val2){?>
  <tr>
    <td><input type="text" name="shop_code[<?php echo $val2['shop_id']?>]" id="shop_code[<?php echo $val2['shop_id']?>]" value="<?php echo $val2['shop_code'];?>" readonly="readonly" /></td>     
	<td><input type="text" name="bf_stocklost[<?php echo $val2['shop_id']?>]" id="bf_stocklost[<?php echo $val2['shop_id']?>]" value="<?php echo $val2['before_stocklost'];?>" readonly="readonly"/></td>
	<td><input type="text" name="current_stocklost[<?php echo $val2['shop_id']?>]" id="current_stocklost[<?php echo $val2['shop_id']?>]" value="<?php echo $val2['current_stocklost'];?>" readonly="readonly"/></td>
	<td><input type="text" name="total[<?php echo $val2['shop_id']?>]" id="total[<?php echo $val2['shop_id']?>]" value="<?php echo ($val2['before_stocklost']+ $val2['current_stocklost']);?>" readonly="readonly" /></td>
	<td><input type="text" name="adj_total[<?php echo $val2['shop_id']?>]" id="adj_total[<?php echo $val2['shop_id']?>]" value="<?php echo ($val2['before_stocklost']+ $val2['current_stocklost']);?>"/></td>
    <?php }?> 

  </tr>

</table>
<br/>
<input type = "submit" name = "next" id = "next" value = "Next" style = "margin-left:850px;"></input>

<?php }?>
</form>



</body>
</html>